package com.springboot.framework.controller;

import com.springboot.framework.annotation.ACS;
import com.springboot.framework.dao.entity.User;
import com.springboot.framework.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(description = "【买家】用户")
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @ACS(allowAnonymous = true)
    @ApiOperation(value = "获取", notes = "")
    @GetMapping("/get")
    public User get(@RequestParam String wechatOpenid) {
        return userService.get(wechatOpenid);
    }

    @ACS(allowAnonymous = true)
    @ApiOperation(value = "新增", notes = "")
    @PostMapping("/insert")
    public int insert(@RequestParam String wechatOpenid) {
        User user = new User();
        user.setWechatOpenid(wechatOpenid);
        return userService.insert(user);
    }
}
